# $ANTLR 3.1 Research.g 2008-09-05 17:03:14

import sys
from antlr3 import *
from antlr3.compat import set, frozenset


# for convenience in actions
HIDDEN = BaseRecognizer.HIDDEN

# token types
String=5
UnicodeEscape=7
Digit=9
EscapeSequence=6
HexDigit=8
EOF=-1
STRING=4


class ResearchLexer(Lexer):

    grammarFileName = "Research.g"
    antlr_version = version_str_to_tuple("3.1")
    antlr_version_str = "3.1"

    def __init__(self, input=None, state=None):
        if state is None:
            state = RecognizerSharedState()
        Lexer.__init__(self, input, state)






    # $ANTLR start "String"
    def mString(self, ):

        try:
            _type = String
            _channel = DEFAULT_CHANNEL

            # Research.g:18:9: ( '\"' ( EscapeSequence | ~ ( '\\u0000' .. '\\u001f' | '\\\\' | '\\\"' ) )* '\"' )
            # Research.g:19:2: '\"' ( EscapeSequence | ~ ( '\\u0000' .. '\\u001f' | '\\\\' | '\\\"' ) )* '\"'
            pass 
            self.match(34)
            # Research.g:19:6: ( EscapeSequence | ~ ( '\\u0000' .. '\\u001f' | '\\\\' | '\\\"' ) )*
            while True: #loop1
                alt1 = 3
                LA1_0 = self.input.LA(1)

                if (LA1_0 == 92) :
                    alt1 = 1
                elif ((32 <= LA1_0 <= 33) or (35 <= LA1_0 <= 91) or (93 <= LA1_0 <= 65534)) :
                    alt1 = 2


                if alt1 == 1:
                    # Research.g:19:8: EscapeSequence
                    pass 
                    self.mEscapeSequence()


                elif alt1 == 2:
                    # Research.g:19:25: ~ ( '\\u0000' .. '\\u001f' | '\\\\' | '\\\"' )
                    pass 
                    if (32 <= self.input.LA(1) <= 33) or (35 <= self.input.LA(1) <= 91) or (93 <= self.input.LA(1) <= 65534):
                        self.input.consume()
                    else:
                        mse = MismatchedSetException(None, self.input)
                        self.recover(mse)
                        raise mse



                else:
                    break #loop1


            self.match(34)



            self._state.type = _type
            self._state.channel = _channel

        finally:

            pass

    # $ANTLR end "String"



    # $ANTLR start "EscapeSequence"
    def mEscapeSequence(self, ):

        try:
            # Research.g:23:2: ( '\\\\' ( UnicodeEscape | 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) )
            # Research.g:23:6: '\\\\' ( UnicodeEscape | 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' )
            pass 
            self.match(92)
            # Research.g:23:11: ( UnicodeEscape | 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' )
            alt2 = 9
            LA2 = self.input.LA(1)
            if LA2 == 117:
                alt2 = 1
            elif LA2 == 98:
                alt2 = 2
            elif LA2 == 116:
                alt2 = 3
            elif LA2 == 110:
                alt2 = 4
            elif LA2 == 102:
                alt2 = 5
            elif LA2 == 114:
                alt2 = 6
            elif LA2 == 34:
                alt2 = 7
            elif LA2 == 39:
                alt2 = 8
            elif LA2 == 92:
                alt2 = 9
            else:
                nvae = NoViableAltException("", 2, 0, self.input)

                raise nvae

            if alt2 == 1:
                # Research.g:23:12: UnicodeEscape
                pass 
                self.mUnicodeEscape()


            elif alt2 == 2:
                # Research.g:23:27: 'b'
                pass 
                self.match(98)


            elif alt2 == 3:
                # Research.g:23:31: 't'
                pass 
                self.match(116)


            elif alt2 == 4:
                # Research.g:23:35: 'n'
                pass 
                self.match(110)


            elif alt2 == 5:
                # Research.g:23:39: 'f'
                pass 
                self.match(102)


            elif alt2 == 6:
                # Research.g:23:43: 'r'
                pass 
                self.match(114)


            elif alt2 == 7:
                # Research.g:23:47: '\\\"'
                pass 
                self.match(34)


            elif alt2 == 8:
                # Research.g:23:52: '\\''
                pass 
                self.match(39)


            elif alt2 == 9:
                # Research.g:23:57: '\\\\'
                pass 
                self.match(92)







        finally:

            pass

    # $ANTLR end "EscapeSequence"



    # $ANTLR start "UnicodeEscape"
    def mUnicodeEscape(self, ):

        try:
            # Research.g:27:2: ( 'u' HexDigit HexDigit HexDigit HexDigit )
            # Research.g:27:4: 'u' HexDigit HexDigit HexDigit HexDigit
            pass 
            self.match(117)
            self.mHexDigit()
            self.mHexDigit()
            self.mHexDigit()
            self.mHexDigit()




        finally:

            pass

    # $ANTLR end "UnicodeEscape"



    # $ANTLR start "HexDigit"
    def mHexDigit(self, ):

        try:
            # Research.g:31:2: ( '0' .. '9' | 'A' .. 'F' | 'a' .. 'f' )
            # Research.g:
            pass 
            if (48 <= self.input.LA(1) <= 57) or (65 <= self.input.LA(1) <= 70) or (97 <= self.input.LA(1) <= 102):
                self.input.consume()
            else:
                mse = MismatchedSetException(None, self.input)
                self.recover(mse)
                raise mse





        finally:

            pass

    # $ANTLR end "HexDigit"



    # $ANTLR start "Digit"
    def mDigit(self, ):

        try:
            # Research.g:35:2: ( '0' .. '9' )
            # Research.g:35:4: '0' .. '9'
            pass 
            self.matchRange(48, 57)




        finally:

            pass

    # $ANTLR end "Digit"



    def mTokens(self):
        # Research.g:1:8: ( String )
        # Research.g:1:10: String
        pass 
        self.mString()








 



def main(argv, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr):
    from antlr3.main import LexerMain
    main = LexerMain(ResearchLexer)
    main.stdin = stdin
    main.stdout = stdout
    main.stderr = stderr
    main.execute(argv)


if __name__ == '__main__':
    main(sys.argv)
